package controllers.features;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import views.features.MainMenuView;
import core.GameLauncher;
import core.GameLauncher.State;

public class MainMenuController implements ActionListener {

	GameLauncher launcher;
	private static MainMenuController instance;

	public static MainMenuController newInstance(MainMenuView view,
			GameLauncher launcher) {
		if (instance == null)
			instance = new MainMenuController(view, launcher);
		return instance;
	}

	private MainMenuController(MainMenuView view, GameLauncher launcher) {
		view.addActionListenerToMenu(this);
		this.launcher = launcher;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		JButton b = (JButton) e.getSource();
		String name = b.getName();
		switch (name) {
		case "gameMenu":
			launcher.startTransition(State.GAME_MENU);
			break;
		case "statistics":
			launcher.startTransition(State.STATISTCS);
			break;
		case "chronology":
			launcher.startTransition(State.CHRONOLOGY);
			break;
		case "classification":
			launcher.startTransition(State.INSTRUCTIONS);
			break;
		}

	}

}
